<template>
  <div>
    <el-card style="width: 1180px">
      <div slot="header" class="clearfix">
        <span>收藏</span>
      </div>
      <el-row :gutter="15">
        <el-col :span="8" v-for="(book, index) in collectedBooks" :key="index">
          <el-card style="margin-bottom: 20px">
            <div>
              <el-col :span="12">
                <img :src="book.bookImage" alt="书籍照片" style="width: 100%; height: 200px;">
              </el-col>
              <el-col :span="12">
                <div style="padding: 14px;">
                  <span>书名: {{ book.bookTitle }}</span>
                  <div class="bottom clearfix">
                    <time class="time">作者: {{ book.bookAuthor }}</time>
                    <div class="bottom clearfix">
                      <span class="price" style="color: #ff6600;">价格: {{ book.bookPrice }}元</span>
                    </div>
                  </div>
                </div>
              </el-col>
            </div>
            <div style="margin-top: 130px;">
              <el-button type="danger" @click="handleRemove(index)">取消收藏</el-button>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      collectedBooks: [
        { bookImage: require('@/assets/1.png'), bookTitle: '书籍1', bookAuthor: '作者1', bookPrice: '50' },
        { bookImage: require('@/assets/2.png'), bookTitle: '书籍2', bookAuthor: '作者2', bookPrice: '60' },
        { bookImage: require('@/assets/3.png'), bookTitle: '书籍3', bookAuthor: '作者3', bookPrice: '70' },
        { bookImage: require('@/assets/4.png'), bookTitle: '书籍4', bookAuthor: '作者4', bookPrice: '80' },
      ]
    }
  },
  methods: {
    handleRemove(index) {
      this.collectedBooks.splice(index, 1);
      this.$message.success('已取消收藏');
    }
  }
}
</script>

<style scoped>
.time {
  font-size: 13px;
  color: #999;
}

.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}
</style>
